Merge pull request #307 from tree-sitter/pointer-sized-cancellation-flag
Make the cancellation flag a size_t, not a uint32_t
This commit is contained in:
commit
82358d3f2f
12 changed files with 31 additions and 30 deletions
|
|
@ -2,7 +2,7 @@ use super::error::{Error, Result};
|
|||
use super::util;
|
||||
use std::io::{self, Write};
|
||||
use std::path::Path;
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::time::Instant;
|
||||
use std::{fs, thread};
|
||||
use tree_sitter::{Language, LogType, Parser};
|
||||
|
|
@ -27,7 +27,7 @@ pub fn parse_file_at_path(
|
|||
// If the `--cancel` flag was passed, then cancel the parse
|
||||
// when the user types a newline.
|
||||
if allow_cancellation {
|
||||
let flag = Box::new(AtomicU32::new(0));
|
||||
let flag = Box::new(AtomicUsize::new(0));
|
||||
unsafe { parser.set_cancellation_flag(Some(&flag)) };
|
||||
thread::spawn(move || {
|
||||
let mut line = String::new();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use super::helpers::edits::{perform_edit, Edit, ReadRecorder};
|
||||
use super::helpers::fixtures::{get_language, get_test_language};
|
||||
use crate::generate::generate_parser_for_grammar;
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::{thread, time};
|
||||
use tree_sitter::{InputEdit, LogType, Parser, Point, Range};
|
||||
|
||||
|
|
@ -303,7 +303,7 @@ fn test_parsing_on_multiple_threads() {
|
|||
|
||||
#[test]
|
||||
fn test_parsing_cancelled_by_another_thread() {
|
||||
let cancellation_flag = Box::new(AtomicU32::new(0));
|
||||
let cancellation_flag = Box::new(AtomicUsize::new(0));
|
||||
|
||||
let mut parser = Parser::new();
|
||||
parser.set_language(get_language("javascript")).unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue